import 'package:flutter/material.dart';
import 'package:test1/pages/animation/Flutter_Animations_Page.dart';
import 'package:test1/pages/data/Flutter_Data_Pages.dart';
import 'package:test1/pages/lifecycle/LifeCycle_Page.dart';
import 'package:test1/pages/net/Flutter_Net_Page.dart';
import 'package:test1/pages/dartbase/DartBase_Page.dart';
import 'package:test1/pages/json/Json_Page.dart';
import 'package:test1/pages/other/Widget_Font_Page.dart';
import 'package:test1/pages/plugs/Plugs.dart';
import 'package:test1/pages/test/Flutter_Test_Pages.dart';
import 'package:test1/pages/utils/Flutter_Utils_Page.dart';
import 'package:test1/pages/widgets/Flutter_Widgets_Page.dart';

//引入自己创建的其他文件
import './bean/ItemInfo.dart';
import './listitems/HomeListItem.dart';
import 'package:test1/pages/Navigator_Page.dart';
import 'package:test1/pages/widgets/Widget_ListView_Builder_Page.dart';
import 'package:test1/pages/widgets/Widget_ListView_Separated_Page.dart';
//import 'package:flutter_webview_plugin/flutter_webview_plugin.dart';

void main() => runApp(new TestApp());

class TestApp extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MyTestApp();
  }
}

class MyTestApp extends State<TestApp> {
  var list = [
    ItemInfo("页面导航"),
    ItemInfo("Dart基础"),
    ItemInfo("Flutter组件"),
    ItemInfo("小练习"),
    ItemInfo("网络请求"),
    ItemInfo("json"),
    ItemInfo("数据与文件存储"),
    ItemInfo("使用自定义字体"),
    ItemInfo("工具类"),
    ItemInfo("动画"),
    ItemInfo("常用插件"),
    ItemInfo("生命周期"),
  ];

  var pageList = [
    Navigator_Page(),
    DartBase_Page(),
    Flutter_Widgets_Page(),
    Flutter_Test_Pages(),
    Flutter_Net_Page(),
    Json_Page(),
    Flutter_Data_Pages(),
    Widget_Font_Page(),
    Flutter_Utils_Page(),
    Flutter_Animations_Page(),
    Plugs(),
    LifeCycle_Page()
  ];

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "flutter学习",
      home: Scaffold(
        appBar: AppBar(title: Text("flutter学习"),),
        body: ListView.builder(
            itemCount: list.length,
            itemBuilder: (context, position) {
              return HomeListItem(position, list[position], (index) =>
                  Navigator.push(context,
                      new MaterialPageRoute(builder: (BuildContext context) {
                        return pageList[index];
                      }))
              );
            }),
      ),
      //不能传递参数,必须在main里面注册
      routes: {
        "listview_builder_page": (BuildContext context) =>
        new ListView_Builder_Page(),
        "listview_separated_page": (BuildContext context) =>
        new ListView_Separated_Page(),

      },
    );
  }
}

